/**
 * 
 */
package com.mindtree.vi.presentation.servlet;

import com.mindtree.vi.business.questionsubmission.AuthenticationManager;
import com.mindtree.vi.presentation.annotation.ReferencedBy;
import com.mindtree.vi.presentation.annotation.RequestParam;
import com.mindtree.vi.xml.XmlResponse;

/**
 * @author m1005309
 * 
 */
public class LoginServlet extends BaseHttpServlet {

	@RequestParam("userId")
	private String userId;

	@RequestParam("password")
	private String password;

	@ReferencedBy("authenticationManager")
	private AuthenticationManager authenticationManager;

	@Override
	public void process() {
		boolean validUser = authenticationManager
				.authenticate(userId, password);

		XmlResponse xmlResponse = new XmlResponse();
		xmlResponse.setMessage(validUser ? "SUCCESSFULLY LOGGED IN!!!"
				: "AUTHENTICATION FAILURE!!!");
		setResponse(xmlResponse);

	}

}
